home *** CD-ROM | disk | FTP | other *** search
/ Atari Mega Archive 1 / Atari Mega Archive - Volume 1.iso / gnu / futils / futl_jgj / man / manpages.zoo / sort.1 < prev    next >
Encoding:
Text File  |  1991-11-11  |  6.9 KB  |  199 lines

  1.  
  2.  
  3.  
  4. SORT(1L)                                                 SORT(1L)
  5.  
  6.  
  7.  
  8. NAME
  9.      sort - sort lines of text files
  10.  
  11. SYNOPSIS
  12.      sort [-cmu] [-t separator] [-o output-file] [-bdfiMnr]
  13.      [+POS1 [-POS2]] [-k POS1[,POS2]] [file...]
  14.  
  15. DESCRIPTION
  16.      This manual page documents the GNU version of sort.  sort
  17.      sorts, merges, or compares all the lines from the given
  18.      files, or the standard input if no files are given.  A file
  19.      name of `-' means standard input.  By default, sort writes
  20.      the results to the standard output.
  21.  
  22.      sort has three modes of operation: sort (the default),
  23.      merge, and check for sortedness.  The following options
  24.      change the operation mode:
  25.  
  26.      -_✓c   Check whether the given files are already sorted: if
  27.           they are not all sorted, print an error message and
  28.           exit with a status of 1.
  29.  
  30.      -_✓m   Merge the given files by sorting them as a group.  Each
  31.           input file should already be individually sorted.  It
  32.           always works to sort instead of merge; merging is pro-
  33.           vided because it is faster, in the case where it works.
  34.  
  35.      A pair of lines is compared as follows: if any key fields
  36.      have been specified, sort compares each pair of fields, in
  37.      the order specified on the command line, according to the
  38.      associated ordering options, until a difference is found or
  39.      no fields are left.
  40.  
  41.      If any of the global options _✓M_✓b_✓d_✓f_✓i_✓n_✓r are given but no key
  42.      fields are specified, sort compares the entire lines accord-
  43.      ing to the global options.
  44.  
  45.      Finally, as a last resort (or if no ordering options were
  46.      specified at all), sort compares the lines byte by byte in
  47.      machine collating sequence.
  48.  
  49.      GNU sort has no limits on input line length or restrictions
  50.      on bytes allowed within lines.  In addition, if the final
  51.      byte of an input file is not a newline, GNU sort silently
  52.      supplies one.  In some cases, such as exactly what the -_✓b
  53.      and -_✓f options do, BSD and System V sort programs produce
  54.      different output; GNU sort follows the POSIX behavior, which
  55.      is usually like the System V behavior.
  56.  
  57.      If the environment variable TMPDIR is set, sort uses it as
  58.      the directory in which to put temporary files instead of the
  59.      default, /tmp.
  60.  
  61.  
  62.  
  63. Page 1
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70. SORT(1L)                                                 SORT(1L)
  71.  
  72.  
  73.  
  74.      The following options affect the ordering of output lines.
  75.      They may be specified globally or as part of a specific key
  76.      field.  If no key fields are specified, global options apply
  77.      to comparison of entire lines; otherwise the global options
  78.      are inherited by key fields that do not specify any special
  79.      options of their own.
  80.  
  81.      -_✓b   Ignore leading blanks when finding sort keys in each
  82.           line.
  83.  
  84.      -_✓d   Sort in `dictionary order': ignore all characters
  85.           except letters, digits and blanks when sorting.
  86.  
  87.      -_✓f   Fold lower case characters into the equivalent upper
  88.           case characters when sorting so that, for example, `b'
  89.           is sorted the same way `B' is.
  90.  
  91.      -_✓i   Ignore characters outside the ASCII range 040-0176
  92.           (inclusive) when sorting.
  93.  
  94.      -_✓M   An initial string, consisting of any amount of white
  95.           space, followed by three letters abbreviating a month
  96.           name, is folded to lower case and compared in the order
  97.           `jan' < `feb' < ... < `dec.'  Invalid names compare low
  98.           to valid names.  This option implies -_✓b.
  99.  
  100.      -_✓n   Compare according to arithmetic value an initial
  101.           numeric string consisting of optional white space, an
  102.           optional - sign, and zero or more digits, optionally
  103.           followed by a decimal point and zero or more digits.
  104.           This option implies -_✓b.
  105.  
  106.      -_✓r   Reverse the result of comparison, so that lines with
  107.           greater key values appear earlier in the output instead
  108.           of later.
  109.  
  110.      Other options are:
  111.  
  112.      -_✓o _✓o_✓u_✓t_✓p_✓u_✓t-_✓f_✓i_✓l_✓e
  113.           Write output to _✓o_✓u_✓t_✓p_✓u_✓t-_✓f_✓i_✓l_✓e instead of to the standard
  114.           output.  If _✓o_✓u_✓t_✓p_✓u_✓t-_✓f_✓i_✓l_✓e is one of the input files, sort
  115.           copies it to a temporary file before sorting and writ-
  116.           ing the output to _✓o_✓u_✓t_✓p_✓u_✓t-_✓f_✓i_✓l_✓e.
  117.  
  118.      -_✓t _✓s_✓e_✓p_✓a_✓r_✓a_✓t_✓o_✓r
  119.           Use character _✓s_✓e_✓p_✓a_✓r_✓a_✓t_✓o_✓r as the field separator when
  120.           finding the sort keys in each line.  By default, fields
  121.           are separated by the empty string between a non-
  122.           whitespace character and a whitespace character.  That
  123.           is to say, given the input line ` foo bar', sort breaks
  124.           it into fields ` foo' and ` bar'.  The field separator
  125.           is not considered to be part of either the field
  126.  
  127.  
  128.  
  129. Page 2
  130.  
  131.  
  132.  
  133.  
  134.  
  135.  
  136. SORT(1L)                                                 SORT(1L)
  137.  
  138.  
  139.  
  140.           preceding or the field following it.
  141.  
  142.      -_✓u   For the default case or the -_✓m option, only output the
  143.           last of a sequence of lines that compare equal.  For
  144.           the -_✓c option, check that no pair of consecutive lines
  145.           compares equal.
  146.  
  147.      +_✓P_✓O_✓S_✓1 [-_✓P_✓O_✓S_✓2]
  148.           Specify a field within each line to use as a sorting
  149.           key.  The field consists of the portion of the line
  150.           starting at POS1 and up to (but not including) POS2 (or
  151.           to the end of the line if POS2 is not given).  The
  152.           fields and character positions are numbered starting
  153.           with 0.
  154.  
  155.      -_✓k _✓P_✓O_✓S_✓1[,_✓P_✓O_✓S_✓2]
  156.           An alternate syntax for specifying sorting keys.  The
  157.           fields and character positions are numbered starting
  158.           with 1.
  159.  
  160.      A position has the form _✓f._✓c, where _✓f is the number of the
  161.      field to use and _✓c is the number of the first character from
  162.      the beginning of the field (for +_✓p_✓o_✓s) or from the end of the
  163.      previous field (for -_✓p_✓o_✓s).  The ._✓c part of a position may be
  164.      omitted in which case it is taken to be the first character
  165.      in the field.  If the -_✓b option has been given, the ._✓c part
  166.      of a field specification is counted from the first nonblank
  167.      character of the field (for +_✓p_✓o_✓s) or from the first nonblank
  168.      character following the previous field (for -_✓p_✓o_✓s).
  169.  
  170.      A +_✓p_✓o_✓s or -_✓p_✓o_✓s argument may also have any of the option
  171.      letters _✓M_✓b_✓d_✓f_✓i_✓n_✓r appended to it, in which case the global
  172.      ordering options are not used for that particular field.
  173.      The -_✓b option may be independently attached to either or
  174.      both of the +_✓p_✓o_✓s and -_✓p_✓o_✓s parts of a field specification,
  175.      and if it is inherited from the global options it will be
  176.      attached to both.  If a -_✓n or -_✓M option is used, thus imply-
  177.      ing a -_✓b option, the -_✓b option is taken to apply to both the
  178.      +_✓p_✓o_✓s and the -_✓p_✓o_✓s parts of a key specification.  Keys may
  179.      span multiple fields.
  180.  
  181.  
  182.  
  183.  
  184.  
  185.  
  186.  
  187.  
  188.  
  189.  
  190.  
  191.  
  192.  
  193.  
  194.  
  195. Page 3
  196.  
  197.  
  198.  
  199.